package com.lzh.prometheus.exceptionhandle.event;

import com.lzh.prometheus.exceptionhandle.interfaces.ExceptionNoticeStatisticsRepository;
import com.lzh.prometheus.message.INoticeSendComponent;
import com.lzh.prometheus.pojos.ExceptionNotice;
import com.lzh.prometheus.properties.exception.ExceptionNoticeFrequencyStrategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.List;

/**
 * @author zhehen.lu
 * @date 2025/8/15 9:30
 */
public class ExceptionNoticeSendListener extends AbstractNoticeSendListener {

    private final static Log logger = LogFactory.getLog(ExceptionNoticeSendListener.class);

    /**
     * @param exceptionNoticeFrequencyStrategy
     * @param exceptionNoticeStatisticsRepository
     * @param noticeSendComponents
     */
    public ExceptionNoticeSendListener(ExceptionNoticeFrequencyStrategy exceptionNoticeFrequencyStrategy,
                                       ExceptionNoticeStatisticsRepository exceptionNoticeStatisticsRepository,
                                       List<INoticeSendComponent<ExceptionNotice>> noticeSendComponents) {
        super(exceptionNoticeFrequencyStrategy, exceptionNoticeStatisticsRepository, noticeSendComponents);
    }

    @Override
    public void onApplicationEvent(ExceptionNoticeEvent event) {
        logger.debug("消息同步发送");
        send(event.getExceptionNotice());
    }

}